package com.farsight.leo.fssmartlock.db;

import com.farsight.leo.fssmartlock.net.bean.DeviceData;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Index;
import androidx.room.OnConflictStrategy;
import androidx.room.PrimaryKey;

/**
 * Author: Administrator
 * Date: 2019/9/17
 * Project: SmartLockApp
 * Description:
 */
@Entity(tableName = "tbl_devices",indices = {@Index(value = {"user_id"},unique = true)})
public class DeviceEntity {
    @PrimaryKey
    @ColumnInfo(name = "_id")
    private Integer id;
    @ColumnInfo(name = "mac_address")
    private String macAddress;
    @ColumnInfo(name = "user_id")
    private int userId;
    @ColumnInfo(name = "user_name")
    private String userName;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMacAddress() {
        return macAddress;
    }

    public void setMacAddress(String macAddress) {
        this.macAddress = macAddress;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void importData(DeviceData deviceData,String userName){
        this.id=deviceData.getDevice_id();
        this.macAddress=deviceData.getMac_address();
        this.userId=deviceData.getUser_id();
        this.userName=userName;
    }

    @Override
    public String toString() {
        return "DeviceEntity{" +
                "id=" + id +
                ", macAddress='" + macAddress + '\'' +
                ", userId=" + userId +
                ", userName='" + userName + '\'' +
                '}';
    }
}
